Web Services

Update an Existing Record Using External Web Service

Description
This customization shows how to use a web service to update data from a web service-based data source. This provides an alternate way to access data than the database stored procedure and inline SQL normally generated by Iron Speed Designer.
Variables
Table Name
Select the database table
Primary Key
Select the primary key field in the table
First Updatable Field
Select an updatable field in the table
Second Updatable Field
Select another updatable field in the table
Applies to
SQLAccessClass class
Code
 
''' 
''' UpdateRecord makes use of Web Service to update a record.
''' 
''' The table to update a record in.
''' The id used to identify the record that will be updated.
''' Function
''' Nothing, or the new  of the inserted record.
Public Overrides Sub UpdateRecord( _
    ByVal table As BaseClasses.Data.TableDefinition, _
    ByVal recordId As BaseClasses.Data.KeyValue, _
    ByVal recValue As BaseClasses.Data.RecordValue, _
    ByVal columnsChanged() As Boolean)

    Dim ${Primary Key} As Integer
    Dim ${First Updatable Field} As String
    Dim ${Second Updatable Field} As String

    ' Get the instance of the data access class.
    Dim myTable As ${${Table Name}ClassName} 
    myTable = ${${Table Name}ClassName}.Instance
    Dim col As BaseColumn

    For Each col In table.ColumnList
        Dim index As Integer = table.ColumnList.IndexOf(col)
        If (col.InternalName = _
            myTable.${First Updatable Field}Column.InternalName) Then
            ${First Updatable Field} = _
            col.ToDatabaseValue(recValue.ColumnValues(index)).ToString()
            
        ElseIf (col.InternalName = _
            myTable.${Second Updatable Field}Column.InternalName) Then
            ${Second Updatable Field} = _
            col.ToDatabaseValue(recValue.ColumnValues(index)).ToString()
            
        ElseIf (col.InternalName = _
            myTable.${Primary Key}Column.InternalName) Then
            ${Primary Key} = CInt(col.ToDatabaseValue( _
            recValue.ColumnValues(index)).ToString())
        End If
    Next

    ' Instantiate the object that will communicate with a web service.
    ' Replace MyWebServiceForTableAccess with the external Web Service name
    Dim webService As New localhost.MyWebServiceForTableAccess
    webService.Credentials = System.Net.CredentialCache.DefaultCredentials

    ' Call the web service's "UpdateRecord" function.
    webService.Update${${Table Name}RecordClassName}(${Primary Key}, _
    ${First Updatable Field}, ${Second Updatable Field})
    
End Sub
     

Terms of Service Privacy Statement